import {
    getLocalStorage,
    removeLocalStorage,
    setLocalStorage
} from './localStore'

enum Keys {
    Token = 'custcareToken',
    ExpireTime = 'custcareExpireTime',
    UserInfo = 'custcareUserInfo'
}
//存储token到session
export const setCustcareToken = (token: string) => {
    setLocalStorage(Keys.Token, token)
}
export const getCustcareToken = () => {
    return getLocalStorage(Keys.Token)
}

export const setCustcareUserInfo = (info: string) => {
    setLocalStorage(Keys.UserInfo, info)
}
export const getCustcareUserInfo = () => {
    const info = getLocalStorage(Keys.UserInfo)
    if (info != null) {
        return JSON.parse(info)
    } else {
        return false
    }
}

//存储过期时间
export const setCustcareExpireTime = (time: number) => {
    setLocalStorage(Keys.ExpireTime, JSON.stringify(time))
}
export const getCustcareExpireTime = () => {
    return getLocalStorage(Keys.ExpireTime)
}
export const cleanCustcareSession = () => {
    removeLocalStorage(Keys.Token)
    removeLocalStorage(Keys.ExpireTime)
    removeLocalStorage(Keys.UserInfo)
}
